<template>
    <div>
      <!-- 搜索栏 -->
        <div class='top'>
                <div class='top-1'><van-icon name="arrow-left" @click="tiaozhuan"/></div>
                <div class='top2' @click="citList">
                  <span>{{$store.state.user.dizhi}} <van-icon name="arrow-down" /></span>
                  <van-icon name="search" class="sou"/>
                  <input type="text" name="" id="" placeholder="请输入小区或地址">
                </div>
                <div class='top-3' @click="search"> <van-icon name="location-o" /></div>
        </div>
      <!-- 查找栏 -->
       <div class="search">
              <!-- <div class="region" >区域 <van-icon name="arrow-down" /></div>
              <div class="mode" >方式 <van-icon name="arrow-down" /></div>
              <div class="rent" >租金 <van-icon name="arrow-down" /></div>
              <div class="screening" >筛选 <van-icon name="arrow-down" /></div> -->
               <van-dropdown-menu :overlay="mask">
                <van-dropdown-item title="区域" >
                    <van-picker :columns="option1" />
                </van-dropdown-item>
                <van-dropdown-item title="方式" >
                  <van-picker :columns="rentType" />
                </van-dropdown-item>
                <van-dropdown-item title="租金" >
                  <van-picker :columns="price" />

                </van-dropdown-item>
                <van-dropdown-item title="筛选" @open='openFilter' > </van-dropdown-item>
              </van-dropdown-menu>
       </div>
      <!-- 主体 -->
       <div class="lie" v-for="(item,index) in list" :key="index" @click="fu(item.houseCode)">
        <div><img :src="`http://liufusong.top:8080${item.houseImg}`" alt=""></div>
        <div class="you">
                  <div class="h3"><h3>{{item.title}}</h3></div>
                  <div class="xiang">{{item.desc}}</div>
                  <p>{{item.tags[0]}}</p>
                  <div class="qina">{{item.price}} <span>元/月</span></div>
        </div>
    </div>

    <!-- 右侧弹出层 -->
    <van-popup
      v-model="show"
      position="right"
      :style="{ height: '100%', width: '78%' }"
    >
      <div class="filter_popup">
        <div class="popup_info">
          <p class="title">户型</p>
          <div class="item">
            <span class="item_info">一室</span>
            <span class="item_info">两室</span>
            <span class="item_info">三室</span>
            <span class="item_info">四室</span>
            <span class="item_info">四室+</span>
          </div>
          <p class="title">朝向</p>
          <div class="item">
            <span class="item_info">东</span>
            <span class="item_info">西</span>
            <span class="item_info">南</span>
            <span class="item_info">北</span>
            <span class="item_info">东南</span>
            <span class="item_info">东北</span>
            <span class="item_info">西南</span>
            <span class="item_info">西北</span>
          </div>
          <p class="title">楼层</p>
          <div class="item">
            <span class="item_info">高楼层</span>
            <span class="item_info">中楼层</span>
            <span class="item_info">低楼层</span>
          </div>
          <p class="title">房屋亮点</p>
          <div class="item">
            <span class="item_info">集中供暖</span>
            <span class="item_info">双卫生间</span>
            <span class="item_info">近地铁</span>
            <span class="item_info">随时看房</span>
            <span class="item_info">精装</span>
            <span class="item_info">公寓</span>
            <span class="item_info">独立卫生间</span>
            <span class="item_info">押一付一</span>
            <span class="item_info">独立阳台</span>
            <span class="item_info">月租</span>
            <span class="item_info">限女生</span>
            <span class="item_info">限男生</span>
            <span class="item_info">新上</span>
          </div>
        </div>
        <div class="foot">
          <span class="cal">清除</span>
          <span class="sure">确定</span>
        </div>
      </div>
    </van-popup>
    </div>
</template>

<script>
import request from '@/utils/request'
export default {
  name: 'VueFind',

  data () {
    return {
      show: false,
      mask: true,
      name: 'find',
      list: [],
      id: this.$store.state.user.name1,
      option1: [
        {
          values: ['区域', '地铁'],
          defaultIndex: 2
        },
        {
          values: ['不限', 'xxxx', 'xxxx'],
          defaultIndex: 1
        }
      ],
      rentType: [],
      price: [
        { text: '不限', value: 'null' },
        { text: '1000及以下', value: 'PRICE|1000' },
        { text: '1000 - 2000', value: 'PRICE|2000' },
        { text: '2000 - 3000', value: 'PRICE|3000' },
        { text: '3000 - 4000', value: 'PRICE|4000' },
        { text: '4000 - 5000', value: 'PRICE|5000' },
        { text: '5000 - 7000', value: 'PRICE|7000' },
        { text: '7000以上', value: 'PRICE|100001' }
      ]
    }
  },

  mounted () {

  },
  // 创建阶段钩子
  created () {
    this.acquire()
    this.diQu()
  },
  methods: {
    openFilter () {
      this.show = true
      this.mask = false
    },
    // 跳到原来的地方
    tiaozhuan () {
      this.$router.go(-1)
    },
    // 跳转到城市页面
    // 跳转城市列表
    citList () {
      this.$router.push(`/citList?uname=${this.name}`)
    },
    // 获取内容接口
    async acquire () {
      const red = await request({
        url: `/houses?cityId=${this.id}&stat=20&end=29`
      })
      console.log(red.body)
      this.list = red.body.list
    },
    // 跳转到地图找房
    search () {
      this.$router.push(`/Map-search?name=${this.name}`)
    },
    // 跳转详情页面
    fu (val) {
      this.$router.push(`/details?val=${val}`)
    },
    // 获取地区的值
    async diQu () {
      const red = await request({
        url: `houses/condition?id=${this.id}`
      })
      console.log(red.body)
      this.rentType = red.body.rentType
      console.log(this.rentType)
    }
  }
}
</script>

<style lang="less" scoped>
*{
  margin: 0;
  padding: 0;
}
// 搜索栏
   .top{
     height: 60px;
     width: 100%;
     background-color: #21b97a;
     display: flex;
     line-height: 60px;
    .top-1 , .top-3{
       width: 15%;
       padding: 0 4%;
       .van-icon {
         margin-top: 18px;
         font-size: 26px;
         color: #fff;
     }
   }
   .sou{
     position: relative;
     left: 9%;
     top: 26%;
     font-size: 20px;
   }
    .top2{
       width: 70%;
       margin-top: 10px;
      height: 40px;
      line-height: 40px;
      background-color: #fff;
      border-radius: 5px;
      justify-content: space-between;
      display: flex;
      span{
         margin-left: 6px;
         width: 24%;
      }
      input{
         margin:8px 0;
         width: 75%;
         height: 25px;
         border: solid 1px #fff;
         font-size: 14px;
         padding-left: 2em;
         border-left:solid 1px #999;
      }
     }
 }
//  查找栏
 .search{
    height: 49px;
    line-height: 50px;
    width: 100%;
    border-bottom: solid 1px #b9b9b9;
    background-color: #fff;
    display: flex;
    /deep/ .van-dropdown-menu__item{
      width: 93.5px;
      text-align: center;
    }
    .van-button--primary {
       background-color: #fff;
       color: #000;
       border: solid 1px #FFF;
    }
 }
 //弹出框
.filter_popup {
  position: fixed;
  top: 0;
  left: 2px;
  right: 0;
  bottom: 0;
  overflow: auto;
  padding-bottom: 50px;
  z-index: 3;
  background-color: #fff;
  .popup_info {
    padding: 0 15px;
    .title {
      margin: 20px 0;
      font-size: 15px;
    }
    .item {
      margin-left: 50px;
      border-bottom: 1px solid #e5e5e5;
      padding-bottom: 14px;
      &:last-child {
        border-bottom: 0;
      }
      .item_info {
        display: inline-block;
        height: 32px;
        width: 70px;
        margin: 0 18px 15px 0;
        border: 1px solid #ddd;
        border-radius: 3px;
        line-height: 32px;
        text-align: center;
        font-size: 12px;
        color: #888;
      }
    }
  }
  .foot {
    text-align: left;
    overflow: hidden;
    display: flex;
    align-items: center;
    position: fixed;
    left: 0px;
    right: 0;
    bottom: 0;
    background-color: #fff;
    z-index: 3;
    align-items: center;
    margin-top: 20px;
    border-top: 1px solid #e9e9e9;
    .cal {
      flex: 1 1;
      border-radius: 0;
      color: #21b97a;
      display: inline-block;
      height: 50px;
      line-height: 50px;
      text-align: center;
      font-size: 18px;
    }
    .sure {
      border-radius: 0;
      flex: 2 1;
      color: #fff;
      background-color: #21b97a;
      display: inline-block;
      height: 50px;
      line-height: 50px;
      text-align: center;
      font-size: 18px;
    }
  }
}
// 主体
.lie{
    height: 120px;
    width: 100%;
    border-bottom: solid 1px #999;
    padding: 10px 0;
    display: flex;
    img{
       width: 140px;
       height: 100px;
       background-color: #ffaeae;
    }
    .you{
       margin-left: 10px;
       .h3{
         height:  25px
       }
       .xiang{
         margin-bottom:  5px ;
       }
       p{
         height: 25px;
         width: 55px;
         background-color: #e1f5f8;
         border-radius: 5px;
         font-size: 14px;
         padding: 5px;
       }
       .qina{
          margin-top: 5px;
          color: red;
          font-size: 18px;
          span{
            font-size: 14px;
          }
      }
    }
}
</style>
